#ifndef __STU_CRS_CPP__
#define __STU_CRS_CPP__
#include "../include/stu_crs.h"


class StuCrs;

void StuCrs::print() {
    Printer::fmtln(L"学号: {:0>8d}, 已选课程号: {:0>8d}", sno, cno);
}

bool StuCrs::found(
    std::vector<std::wstring>& strs,
    std::vector<int>& code) {

    bool can = true;
    std::partial_ordering res;

    for (int i = 0; code[i] && can; i += 3) {
        // 这些魔法数字的说明请看 parse<StuCrs>() 的注释.
        if (code[i] == 0x01) { res = sno <=> code[i + 2]; }
        if (code[i] == 0x02) { res = cno <=> code[i + 2]; }

        switch (code[i + 1]) {
        case 0x11: if (res == 0) continue; goto NG;
        case 0x12: if (res != 0) continue; goto NG;
        case 0x13: if (res <  0) continue; goto NG;
        case 0x14: if (res <= 0) continue; goto NG;
        case 0x15: if (res >  0) continue; goto NG;
        case 0x16: if (res >= 0) continue; goto NG;
        }
        NG:
        can = false;
    }
    return can;
}


#endif /* __STU_CRS_CPP__ */
